﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/FullSite.Master" Inherits="System.Web.Mvc.ViewPage<ToppingControl.Models.TopCordPlanModel.TopCordPlan_DS>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
   New_Sample</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="float-left">
        <h2 style="color: #191970">
      Head Operator</h2>
   </div>
   <div class="float-right">
      <div class="float-left">
         <h3>
            Topping NO.
            <%: Html.DisplayFor(model => model._Topno) %>
         </h3>
      </div>
      <div class="float-left" style="margin-left: 25px;">
         <h3>
            Shift : <%: ViewBag.shift %></h3>
      </div>
      <div class="float-left" style="margin-left: 25px;">
         <h3>
            Name :
            <% if (Request.IsAuthenticated)
               { %>
            <%:  User.Identity.Name %></h3>
      </div>
      <% } %>
   </div>
   <style type="text/css">
      .fontTB
      {
         font-size: 16pt !important;
      }
      input[type="text"]
      {
         font-size: 20px;
         height: 1.5em;
         line-height: 2em;
         width:75%;
      }
      .btn
      {
         font-size: 20px !important;
      }
      .ui-widget-header
      {
         background: url("images/ui-bg_gloss-wave_35_f6a828_500x100.png") repeat-x scroll 50% 50% #F6A828;
         border: 1px solid #E78F08;
         color: #FFFFFF;
         font-weight: bold;
      }
        #run,#finish
        {
        background-color:Red;
        color:Black;
        }
        #run:hover,#finish:hover
        {
        color:White;
        }
      /* Bigger text */
      </style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="TableContent" runat="server">
    <%  if (WinNemoLib.StrUtil.IsEmpty(Model._Runflag))
        { %>
      <div class="float-left" style="margin: 15px;">
          <input id="back" type="button" value="BACK" class="btnFooter shadow" style="height: 75px;   width: 350px;" />
      </div>
      <div class="float-right" style="margin: 15px;">
          <input id="run" type="button" value="Run" class="btnFooter shadow" style="height: 75px;  width: 350px;" />
      </div>
      <%}
        else
        { %>
         <div class="float-left" style="margin: 15px;">
               <input id="finish" type="button" value="FINISH" class="btnFooter shadow" style="height: 75px;   width: 350px;" />
            </div>
        <div class="float-right" style="margin:15px;">
         <input type="button" id="com" value="Change Compound" class="btnFooter shadow" style="height: 75px; width: 350px;" />
        </div>
      <%} %>
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="MainContent2" runat="server">
    <div class="fontTB" style="text-align:center; line-height:40px;">NEW SIMPLE</div>
   <div>
   
   <table width="75%" style="height:82%" >
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px; width: 35%;">
            SEQ
         </td>
         <td class="cell" id="seqDT">
            <%=  Model._Plandt + '-' + Model._Itemno %>
         </td>
      </tr>
      <% 
     
      if  (WinNemoLib.StrUtil.IsNotEmpty(Model._Runflag))
       { %>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Topped Cord
         </td>
         <td class="cell">
            <%= Model._Topcrdcd%>
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Manufacturer
         </td>
         <td class="cell">
            <%= Model._Manufc %>
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Length (M.)
         </td>
         <td class="cell">
            <%= Model._Length%>
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Tire Cord
         </td>
         <td class="cell" id="code">
            <%= Model._Tcrdcd %>
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Tire Cord Lot
         </td>
         <td class="cell" id="lot">
            <%=Model._Tcrdlot %>
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Tire Cord Expire
         </td>
         <td class="cell" id="exp">
            <%=Model._Tcrdexp %>
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Tire Cord Tag Length (M.)
         </td>
         <td class="cell">
            <%=Model._Tcrdtagl %>
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Tire Cord Tag Width (cm.)
         </td>
         <td class="cell">
            <%=Model._Tcrdtagw %>
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Tire Cord Width (cm.)
         </td>
         <td class="cell">
            <%=Model._Tcrdw %>
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Compound
         </td>
         <td class="cell" id="mComp">
            <%=Model._Compcd %>
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Compound Lot
         </td>
         <td class="cell" id="comp">
            <%=Model._Complot %>
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Compound Pallet
         </td>
         <td class="cell" id="Td1">
            <%=Model._Comppllt %>
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Compound Expired
         </td>
         <td class="cell" id="Td2">
            <%=Model._Compexp %>
         </td>
      </tr>
      <tr class="rowb">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Compound (Kg.)
         </td>
         <td class="cell" id="Td3">
            <%=Model._Compw %>
         </td>
      </tr>
      <tr>
         <td colspan="2">
            <div id="progressbar">
            </div>
         </td>
      </tr>

      <%} else { %>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Topped Cord
         </td>
         <td class="cell">
            <input type="text" id="txtcode" class="request" maxlength="30" />
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Manufacturer
         </td>
         <td class="cell">
          <input type="text" id="txtcus"  class="request" maxlength="18"/>
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Length (M.)
         </td>
         <td class="cell">
            <input type="text" id="txtlen" class="request" maxlength="6" />
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Tire Cord
         </td>
         <td class="cell" id="Td4">
            <input id="txtTire" type="text"class="request" maxlength="30" />
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Tire Cord Lot
         </td>
         <td class="cell" id="Td5">
            <input type="text" id="txtlot" class="request" maxlength="10"/>
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Tire Cord Expire
         </td>
         <td class="cell" id="Td6">
            <input type="text" id="txtexp" class="request" />
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Tire Cord Tag Length (M.)
         </td>
         <td class="cell">
            <input type="text" id="txtTagL" class="request" maxlength="7"/>
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Tire Cord Tag Width (cm.)
         </td>
         <td class="cell">
            <input type="text" id="txtTagw" class="request" maxlength="5"/>
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Tire Cord Width (cm.)
         </td>
         <td class="cell">
            <input type="text" id="txtTirW" class="request" maxlength="5"/>
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Compound
         </td>
         <td class="cell" id="Td7">
            <input type="text" id="txtCpd" class="request" maxlength="30"/>
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Compound Lot
         </td>
         <td class="cell" id="Td8">
            <input type="text" id="txtCpdLot" class="request" maxlength="6"/>
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Compound Pallet
         </td>
         <td class="cell" id="Td9">
            <input type="text" id="txtCpdPl" class="request" maxlength="4"/>
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Compound Expired
         </td>
         <td class="cell" id="Td10">
            <input type="text" id="txtCpdExp" class="request"/>
         </td>
      </tr>
      <tr class="rowa">
         <td class="head cell text-right" style="padding: 10px 0px;">
            Compound (Kg.)
         </td>
         <td class="cell" id="Td11">
            <input type="text" id="txtCpdKg" class="request" maxlength="8"/>
         </td>
      </tr>
      <tr>
         <td colspan="2">
        
         </td>
      </tr>
      <% } %>
   </table>
   </div>
   
   
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="ScriptsSection" runat="server">
    <% if (false)
      { %>
   <script src="../../Scripts/jquery-1.7.2.js" type="text/javascript"></script>
   <% } %>
   <script type="text/jscript">
      function updateProgress() {
         var progress;
         progress = $("#progressbar")
         .progressbar("option", "value");
         if (progress < 100) {
            $("#progressbar")
            .progressbar("option", "value", progress + 1);
            setTimeout(updateProgress, 500);
         }
         else {
            $("#progressbar").progressbar({ value: 0 });
            setTimeout(updateProgress, 500);
         }
      }
      $(function () {
         $("#progressbar").progressbar({ value: 0 });
         setTimeout(updateProgress, 500);

         $("#txtexp,#txtCpdExp").dateEntry({ dateFormat: 'dmy/' });
         $("#body").css("padding-bottom", "0");
         $("#txtlen").setMask("9999.999").addClass("right");
         $("#txtTagL").setMask("9999.999").addClass("right");
         $("#txtTirW,#txtTagw").setMask("999.99").addClass("right");
         $("#txtCpdKg").setMask("9999.999").addClass("right");
           $("#com").click(function () {
             var getUsersUrl = '<%=Url.Action("CPC_CHANGE","CPD_USE") %>' + '?seq=' + $.trim($("#seqDT").text());
                 window.location = getUsersUrl + '&back=' + '<%= Url.Action("New_Sample","HeaderLine") %>';
          });

         $("#run").click(function () {
            var blnR = 'true';
            $(".request").each(function () {
               $(this).parent().find("font").empty();
               if ($(this).val() == '') {
                  if (blnR == 'true') {
                     blnR = false;
                     $(this).focus();
                     alert('ระบุค่าไม่ครบ');
                  }
                  $(this).parent().append("<font color='red'>*</font>");
                  return;
               }
            });
            var data = new Array();
            if (blnR == 'true') {
               var getUsersUrl = '<%=Url.Action("Save_Sample","HeaderLine") %>';
               var act = '<%=Url.Action("New_Sample","HeaderLine") %>' + '?seq=' + $.trim($("#seqDT").text());
               callScriptMethod(getUsersUrl, {
                  thedata: {
                     _Topno: '1',
                     _Itemno: '<%:Model._Itemno %>',
                     _Plandt: '<%:Model._Plandt %>',
                     _Topcrdcd: $("#txtcode").val(),
                     _Manufc: $("#txtcus").val(),
                     _Length: $("#txtlen").val(),
                     _Plants: 'L',
                     _UpTemp: '<%: User.Identity.Name %>',
                     _Empname: '<%: User.Identity.Name %>',
                     _Tcrdcd: $("#txtTire").val(),
                     _Tcrdlot: $("#txtlot").val(),
                     _Tcrdexp: $("#txtexp").val(),
                     _Tcrdtagl: $("#txtTagL").val(),
                     _Tcrdtagw: $("#txtTagw").val(),
                     _Tcrdw: $("#txtTirW").val(),
                     _Compcd: $("#txtCpd").val(),
                     _Complot: $("#txtCpdLot").val(),
                     _Comppllt: $("#txtCpdPl").val(),
                     _Compexp: $("#txtCpdExp").val(),
                     _Compw: $("#txtCpdKg").val(),
                     _Shift: '<%:  ViewBag.shift %>'
                  }
               }, act)
            }

         }); /**** Run ****/


         $("#finish").click(function () {
            var getUsersUrl = '<%=Url.Action("Upd_Status","HeaderLine") %>';
            var action = '<%= Url.Action("Header_line","HeaderLine") %>'
            callScriptMethod(getUsersUrl, { seq: $.trim($("#seqDT").text()), status: 'F' }, action);
         });

         $("#back").click(function () {
            var url = '<%= Url.Action("Header_line","HeaderLine") %>';
            window.location = url;
         });

         /********* AJAX ********/

         function callScriptMethod(url, jsonObject, action, callback, async) {

            callback = callback || function () { };
            async = (async == null || async);

            $.ajax({
               type: "POST",
               contentType: "application/json; charset=utf-8",
               url: url,
               data: JSON.stringify(jsonObject),
               dataType: "json",
               async: async,
               success: function (data) {
                  if (data.success != "0") {

                     window.location = action;
                  } else alert(data.message);
               },
               error: function (xhr, status, error) {
                  var err = xhr.responseText;
                  alert(err.Message);
               }
            });
         }

      });

   </script>
</asp:Content>
